package com.lmn.actuator;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;


/**
 * @describe: 通过接口方式实现对 health 的扩展
 *
 * http://localhost:1234/monitor/manage/health
 */
@Component("myHealth_interface")
public class MyHealthIndicator implements HealthIndicator {

    @Override
    public Health health() {
        //健康检查实现
        int errorCode = check();
        if (errorCode != 0) {
            return Health.down().withDetail("Error Code", errorCode).build();
        }
        return Health.up().build();
    }


    /**
     * 健康检查实现
     */
    public int check() {
        return 0;
    }
}
